package com.massimilla.calculator;

import java.util.*;

public class Main {
	// Creating operation functions
	public static double add(double num1, double num2) {
		double result = num1 + num2;
		return result;
	}

	public static double sub(double num1, double num2) {
		double result = num1 - num2;
		return result;
	}

	public static double mult(double num1, double num2) {
		double result = num1 * num2;
		return result;
	}

	public static double div(double num1, double num2) {
		double result = num1 / num2;
		return result;
	}

	public static double exp(double num1, double num2) {
		double result = Math.pow(num1, num2);
		return result;
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		boolean run = true;
		double result = 0;

		// Obtaining first number
		System.out.println("Please enter your first number.");
		Scanner scannum = new Scanner(System.in);
		double num1 = scannum.nextInt();

		// Obtaining operation
		System.out.println("Please enter your prefered operation.");
		String opstr = scannum.next();

		// Obtaining second number
		System.out.println("Please enter your second number.");
		double num2 = scannum.nextInt();

		// Performing calculation
		if (opstr.equals("+") || opstr.equalsIgnoreCase("add") || opstr.equalsIgnoreCase("addition") || opstr.equalsIgnoreCase("added")) {
			result = add(num1, num2);
		} else if (opstr.equals("-") || opstr.equalsIgnoreCase("subtract") || opstr.equalsIgnoreCase("subtracted") || opstr.equalsIgnoreCase("minus") || opstr.equalsIgnoreCase("subtraction")) {
			result = sub(num1, num2);
		} else if (opstr.equals("/") || opstr.equalsIgnoreCase("divide") || opstr.equalsIgnoreCase("divided") || opstr.equalsIgnoreCase("division")) {
			result = mult(num1, num2);
		} else if (opstr.equals("*") || opstr.equalsIgnoreCase("multipy") || opstr.equalsIgnoreCase("multiplied") || opstr.equalsIgnoreCase("multiplication")) {
			result = div(num1, num2);
		} else if (opstr.equals("^") || opstr.equalsIgnoreCase("powered") || opstr.equalsIgnoreCase("exponent") || opstr.equalsIgnoreCase("power") || opstr.equalsIgnoreCase("exponented") || opstr.equalsIgnoreCase("powers") || opstr.equalsIgnoreCase("exponented")) {
			result = exp(num1, num2);
		}

		// Prevents invalid entries
		else {
			System.out.println("Your calculation is invalid");
			run = false;
		}
		scannum.close();
		if (run == true) {
			System.out.println("The result is " + result);
		}
	}

}
